/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.ArrayMethod;
import org.xtext.example.cr.cR.Assignment;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Element;
import org.xtext.example.cr.cR.Function;
import org.xtext.example.cr.cR.VarDec;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.ElementImpl#getVarDec <em>Var Dec</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ElementImpl#getAssignment <em>Assignment</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ElementImpl#getArrayMethod <em>Array Method</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ElementImpl#getFunction <em>Function</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ElementImpl extends MinimalEObjectImpl.Container implements Element
{
  /**
   * The cached value of the '{@link #getVarDec() <em>Var Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVarDec()
   * @generated
   * @ordered
   */
  protected VarDec varDec;

  /**
   * The cached value of the '{@link #getAssignment() <em>Assignment</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAssignment()
   * @generated
   * @ordered
   */
  protected Assignment assignment;

  /**
   * The cached value of the '{@link #getArrayMethod() <em>Array Method</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArrayMethod()
   * @generated
   * @ordered
   */
  protected ArrayMethod arrayMethod;

  /**
   * The cached value of the '{@link #getFunction() <em>Function</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFunction()
   * @generated
   * @ordered
   */
  protected Function function;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ElementImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.ELEMENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public VarDec getVarDec()
  {
    return varDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetVarDec(VarDec newVarDec, NotificationChain msgs)
  {
    VarDec oldVarDec = varDec;
    varDec = newVarDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__VAR_DEC, oldVarDec, newVarDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVarDec(VarDec newVarDec)
  {
    if (newVarDec != varDec)
    {
      NotificationChain msgs = null;
      if (varDec != null)
        msgs = ((InternalEObject)varDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__VAR_DEC, null, msgs);
      if (newVarDec != null)
        msgs = ((InternalEObject)newVarDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__VAR_DEC, null, msgs);
      msgs = basicSetVarDec(newVarDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__VAR_DEC, newVarDec, newVarDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Assignment getAssignment()
  {
    return assignment;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAssignment(Assignment newAssignment, NotificationChain msgs)
  {
    Assignment oldAssignment = assignment;
    assignment = newAssignment;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__ASSIGNMENT, oldAssignment, newAssignment);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAssignment(Assignment newAssignment)
  {
    if (newAssignment != assignment)
    {
      NotificationChain msgs = null;
      if (assignment != null)
        msgs = ((InternalEObject)assignment).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__ASSIGNMENT, null, msgs);
      if (newAssignment != null)
        msgs = ((InternalEObject)newAssignment).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__ASSIGNMENT, null, msgs);
      msgs = basicSetAssignment(newAssignment, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__ASSIGNMENT, newAssignment, newAssignment));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArrayMethod getArrayMethod()
  {
    return arrayMethod;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetArrayMethod(ArrayMethod newArrayMethod, NotificationChain msgs)
  {
    ArrayMethod oldArrayMethod = arrayMethod;
    arrayMethod = newArrayMethod;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__ARRAY_METHOD, oldArrayMethod, newArrayMethod);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArrayMethod(ArrayMethod newArrayMethod)
  {
    if (newArrayMethod != arrayMethod)
    {
      NotificationChain msgs = null;
      if (arrayMethod != null)
        msgs = ((InternalEObject)arrayMethod).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__ARRAY_METHOD, null, msgs);
      if (newArrayMethod != null)
        msgs = ((InternalEObject)newArrayMethod).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__ARRAY_METHOD, null, msgs);
      msgs = basicSetArrayMethod(newArrayMethod, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__ARRAY_METHOD, newArrayMethod, newArrayMethod));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Function getFunction()
  {
    return function;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFunction(Function newFunction, NotificationChain msgs)
  {
    Function oldFunction = function;
    function = newFunction;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__FUNCTION, oldFunction, newFunction);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFunction(Function newFunction)
  {
    if (newFunction != function)
    {
      NotificationChain msgs = null;
      if (function != null)
        msgs = ((InternalEObject)function).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__FUNCTION, null, msgs);
      if (newFunction != null)
        msgs = ((InternalEObject)newFunction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.ELEMENT__FUNCTION, null, msgs);
      msgs = basicSetFunction(newFunction, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ELEMENT__FUNCTION, newFunction, newFunction));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.ELEMENT__VAR_DEC:
        return basicSetVarDec(null, msgs);
      case CRPackage.ELEMENT__ASSIGNMENT:
        return basicSetAssignment(null, msgs);
      case CRPackage.ELEMENT__ARRAY_METHOD:
        return basicSetArrayMethod(null, msgs);
      case CRPackage.ELEMENT__FUNCTION:
        return basicSetFunction(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.ELEMENT__VAR_DEC:
        return getVarDec();
      case CRPackage.ELEMENT__ASSIGNMENT:
        return getAssignment();
      case CRPackage.ELEMENT__ARRAY_METHOD:
        return getArrayMethod();
      case CRPackage.ELEMENT__FUNCTION:
        return getFunction();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.ELEMENT__VAR_DEC:
        setVarDec((VarDec)newValue);
        return;
      case CRPackage.ELEMENT__ASSIGNMENT:
        setAssignment((Assignment)newValue);
        return;
      case CRPackage.ELEMENT__ARRAY_METHOD:
        setArrayMethod((ArrayMethod)newValue);
        return;
      case CRPackage.ELEMENT__FUNCTION:
        setFunction((Function)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ELEMENT__VAR_DEC:
        setVarDec((VarDec)null);
        return;
      case CRPackage.ELEMENT__ASSIGNMENT:
        setAssignment((Assignment)null);
        return;
      case CRPackage.ELEMENT__ARRAY_METHOD:
        setArrayMethod((ArrayMethod)null);
        return;
      case CRPackage.ELEMENT__FUNCTION:
        setFunction((Function)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ELEMENT__VAR_DEC:
        return varDec != null;
      case CRPackage.ELEMENT__ASSIGNMENT:
        return assignment != null;
      case CRPackage.ELEMENT__ARRAY_METHOD:
        return arrayMethod != null;
      case CRPackage.ELEMENT__FUNCTION:
        return function != null;
    }
    return super.eIsSet(featureID);
  }

} //ElementImpl
